var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  e = require("../../../utils/http"),
  a = t(require("../../../utils/util")),
  n = new e.HTTP;
Page({
  data: {
    xingenjin: "请选择",
    currentDate: (new Date).getTime(),
    minDate: new Date(2022, 0, 1).getTime(),
    formatter: function (t, e) {
      return "year" === t ? "".concat(e, "年") : "month" === t ? "".concat(e, "月") : e
    },
    show: !1,
    tname: !1,
    zhuti: [],
    checkedItem: "李秋建",
    checkedItems: "青澜实业"
  },
  onitemclick: function (t) {
    var e = this,
      a = e.data.zhuti[t.currentTarget.id].text;
    n.request({
      url: "https://www.qlsyyun.com:3000/reassignm",
      data: {
        bumen: a
      }
    }).then((function (t) {
      e.setData({
        bailey: t.data
      })
    }));
    var i = t.currentTarget.dataset.classify.text;
    e.setData({
      checkedItems: i
    })
  },
  quxiaos: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  jnameclick: function (t) {
    var e = t.currentTarget.dataset.classify.jname;
    this.setData({
      checkedItem: e
    })
  },
  preventTouchMove: function (t) {},
  queren: function () {
    var t = this.data.checkedItem;
    console.log(t),
      this.setData({
        tname: !1,
        xingenjin: t
      })
  },
  selectEvent: function (t) {
    this.setData({
      sortType: t.detail.selectedID,
      nowText: t.detail.nowText
    })
  },
  closeTime: function () {
    this.setData({
      show: !0
    })
  },
  onInput: function (t) {
    this.setData({
      currentDate: t.detail
    })
  },
  onConfirm: function (t) {
    var e = a.default.formatStamp(t.detail + 7776e6),
      n = a.default.formatStamp(t.detail);
    this.setData({
        show: !1,
        yjdc: n,
        dqsj: e
      }),
      console.log(this.data.yjdc, this.data.dqsj, "yjdc")
  },
  onCancel: function () {
    this.setData({
      show: !1,
      ydsj: "请选择预定达成的日期"
    })
  },
  opentime: function () {
    this.setData({
      show: !0
    })
  },
  opentname: function () {
    this.setData({
      tname: !0
    })
  },
  quxiao: function () {
    this.setData({
      tname: !1
    })
  },
  onLoad: function (t) {
    var e = this;
    n.request({
        url: "https://www.qlsyyun.com:3000/reassignment"
      }).then((function (t) {
        e.setData({
          zhuti: t.data
        })
      })),
      n.request({
        url: "https://www.qlsyyun.com:3000/reassignm",
        data: {
          bumen: "青澜实业"
        }
      }).then((function (t) {
        e.setData({
          bailey: t.data
        })
      }));
    var a = (new Date).getTime(),
      i = new Date(parseInt(a + 7776e6)).toLocaleString().replace(/年|月|日/g, "-").slice(0, 10).replace("上午", "").replace("下午", "").replace(/\//g, "-"),
      s = new Date(parseInt(a)).toLocaleString().replace(/年|月|日/g, "-").slice(0, 10).replace("上午", "").replace("下午", "").replace(/\//g, "-"),
      o = wx.getStorageSync("user")[0];
    e.setData({
        bID: t.bid,
        yjdc: s,
        nowtime: s,
        nowname: o,
        dqsj: i
      }),
      n.request({
        url: "https://www.qlsyyun.com:3000/information",
        data: {
          bID: e.data.bID
        }
      }).then((function (t) {
        e.setData({
          infor: t.data[0]
        })
      }))
  },
  formSubmit: function (t) {
    var e = this;
    wx.showModal({
      title: "提示",
      content: "请核对数据是否准确",
      success: function (t) {
        t.confirm && ("请选择" != e.data.xingenjin ? n.request({
          url: "https://www.qlsyyun.com:3000/allocation/zscb",
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          method: "POST",
          data: {
            bID: e.data.bID,
            bm: e.data.checkedItems,
            zsy: e.data.xingenjin,
            zsks: e.data.yjdc,
            zsdq: e.data.dqsj
          }
        }).then((function (t) {
          n.request({
              url: "https://www.qlsyyun.com:3000/allocation/stjd",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                bID: e.data.bID,
                tjsj: e.data.yjdc,
                qymc: e.data.infor.qymc,
                bm: e.data.checkedItems,
                zsy: e.data.xingenjin,
                tname: e.data.nowname
              }
            }).then((function (t) {})),
            n.request({
              url: "https://www.qlsyyun.com:3000/allocation/stmx",
              header: {
                "Content-Type": "application/x-www-form-urlencoded"
              },
              method: "POST",
              data: {
                tname: e.data.nowname,
                qymc: e.data.infor.qymc,
                zsy: e.data.xingenjin,
                bm: e.data.checkedItems,
                bID: e.data.bID,
                tjsj: e.data.nowtime
              }
            }).then((function (t) {
              var e = getCurrentPages();
              e[e.length - 2].setData({
                  a: 0
                }),
                wx.navigateBack({
                  delta: 1
                })
            }))
        })) : wx.showToast({
          title: "请选择新跟进招商员",
          icon: "none",
          duration: 1e3
        }))
      }
    })
  }
});